import Mock from 'mockjs';

// const img = require('@/assets/images/index/verify.png');
// // 图片验证码接口
// Mock.mock('/api/capture', 'get', function () {
//     return img;
// });

// 登录接口
Mock.mock('/api/user/login', {
    code: 200,
    msg: '登录成功',
    success: true,
    data: {
        user: { name: '彭于晏', age: 18, rank: 10, avatarImg: require('@/assets/images/index/guohui.png'), balance: 29.9 },
        token: 'joaaohiefuopieeaskfoefeop', //token随便乱写
    },
});
// 注册
Mock.mock('/api/user/register', {
    code: 200,
    msg: '注册成功',
    success: true,
});
// 验证 验证码
Mock.mock('/send/code', {
    code: 200,
    msg: '成功',
    success: true,
    data: {
        user: { name: '彭于晏', age: 18, rank: 10, balance: 29.9 },
    },
});
// 通过手机号获取验证码
Mock.mock('/get/code', {
    code: 200,
    msg: '成功',
    success: true,
    data: {
        user: { name: '彭于晏', age: 18, rank: 10, balance: 29.9 },
    },
});
// 上传接口
Mock.mock('/send/password', {
    code: 200,
    msg: '成功',
    success: true,
    data: {
        user: { name: '彭于晏', age: 18, rank: 10, balance: 29.9 },
    },
});
// 验证后四位密码
Mock.mock('/valid/password', {
    code: 200,
    msg: '成功',
    success: true,
    data: {
        user: { name: '彭于晏', age: 18, rank: 10, balance: 29.9 },
    },
});
// 获取用户分享信息
Mock.mock('/info/share', {
    code: 200,
    msg: '获取成功!',
    success: true,
    data: {
        user: { name: '彭于晏', age: 18, rank: 10, avatarImg: require('@/assets/images/index/avatar.jpg'), price: 1980.0 },
    },
});
// 获取验证码
Mock.mock('/get/code', 'get', {
    code: 200,
    success: true,
    msg: '验证码发送成功！',
    // data: {
    //     code: '1234',
    // },
});
// 查询用户绑定的银行列表
Mock.mock('/get/infos', {
    code: 200,
    success: true,
    data: {
        name: '迪丽热巴',
        amount: 29.9,
    },
});
// 短信平台验证码接口
Mock.mock('/api/user/getVerifyCode', 'post', option => {
    // JSON.parse(option.body) 为参数
    // JSON.parse(option.body).tel  手机号
    return {
        code: 200,
        success: true,
        msg: '发送成功！',
    };
});

Mock.mock('/api/user/bind', 'post', option => {
    console.log(option);
    // JSON.parse(option.body) 为参数 对象
    return {
        code: 200,
        success: true,
        msg: '绑定成功！',
    };
});
Mock.mock('/get/code', 'post', {
    code: 200,
    success: true,
    msg: '验证码发送成功!',
    data: {
        code: '123456',
    },
});

Mock.mock('/api/my/list', 'post', ({ body }) => {
    const { activeNum } = JSON.parse(body);
    if (activeNum) {
        return {
            code: 200,
            success: true,
            data: [
                {
                    money: '388',
                    companyName: 'iPhone企业店2',
                    title: '商品优惠券3',
                    sub: '限该店铺内指定商品可用3',
                    url: 'https://wx3.sinaimg.cn/mw690/005ZwWLZly1hn5xm1f9k9j31jk111aoz.jpg',
                },
            ],
        };
    } else {
        return {
            code: 200,
            success: true,
            data: [
                {
                    money: '399',
                    companyName: 'iPhone企业店',
                    title: '商品优惠券',
                    sub: '限该店铺内指定商品可用',
                    url: 'https://p3.toutiaoimg.com/large/tos-cn-i-qvj2lq49k0/b617f37569d8445cbd39446c2cc72944.jpg',
                },
                {
                    money: '388',
                    companyName: 'iPhone企业店2',
                    title: '商品优惠券3',
                    sub: '限该店铺内指定商品可用3',
                    url: 'https://wx3.sinaimg.cn/mw690/005ZwWLZly1hn5xm1f9k9j31jk111aoz.jpg',
                },
            ],
        };
    }
});
